<script setup>
import { useSubjectStore } from '@/stores'
const subjectStore = useSubjectStore()
const setAE = (data) => {
  subjectStore.setAE(data).then((code) => {
    if (code === true) {
      ElMessage.success('成功')
    } else {
      ElMessage.error('失败')
    }
  })
}
const degree = [
  {
    value: 1,
    label: '轻度',
    label1: '肯定有关'
  },
  {
    value: 2,
    label: '中度',
    label1: '可能有关'
  },
  {
    value: 3,
    label: '重度',
    label1: '无关'
  }
]
const results = [
  {
    value: 1,
    label: '恢复'
  },
  {
    value: 2,
    label: '恢复但留有后遗症'
  },
  {
    value: 3,
    label: '死亡'
  },
  {
    value: 4,
    label: '不知道'
  },
  {
    value: 5,
    label: '未恢复'
  }
]
const isExit = [
  {
    value: 0,
    label: '否'
  },
  {
    value: 1,
    label: '是'
  }
]
</script>
<template>
  <el-table :data="subjectStore.AE" stripe>
    <el-table-column prop="week" label="时间" width="40" />
    <el-table-column label="不良事件名称" width="100">
      <template #default="scope">
        <el-input v-model="scope.row.name" placeholder="请输入" />
      </template>
    </el-table-column>
    <el-table-column label="发生日期" width="150">
      <template #default="scope">
        <el-date-picker
          v-model="scope.row.startDate"
          type="date"
          placeholder="发生日期"
          style="width: 100%"
        />
      </template>
    </el-table-column>
    <el-table-column label="结束日期" width="150">
      <template #default="scope">
        <el-date-picker
          v-model="scope.row.finishDate"
          type="date"
          placeholder="结束日期"
          style="width: 100%"
        />
      </template>
    </el-table-column>
    <el-table-column label="严重程度" width="99">
      <template #default="scope">
        <el-select
          v-model="scope.row.degree"
          placeholder="Select"
          style="width: 75px"
        >
          <el-option
            v-for="item in degree"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="采取的措施" width="80">
      <template #default="scope">
        <el-input v-model="scope.row.measure" placeholder="请输入" />
      </template>
    </el-table-column>
    <el-table-column label="与治疗措施的相关性" width="124">
      <template #default="scope">
        <el-select
          v-model="scope.row.relativity"
          placeholder="Select"
          style="width: 100px"
        >
          <el-option
            v-for="item in degree"
            :key="item.value"
            :label="item.label1"
            :value="item.value"
          />
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="结果">
      <template #default="scope">
        <el-select v-model="scope.row.result" placeholder="Select">
          <el-option
            v-for="item in results"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="该患者是否因不良事件而退出研究">
      <template #default="scope">
        <el-select v-model="scope.row.isExit" placeholder="Select">
          <el-option
            v-for="item in isExit"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="提交">
      <template #default="scope">
        <el-button @click="setAE(scope.row)">确定</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<style lang="scss" scoped></style>
